package com.doit.hbase.client;

import com.doit.hbase.utils.HbaseUtils;
import org.apache.hadoop.hbase.TableName;
import org.apache.hadoop.hbase.client.Admin;
import org.apache.hadoop.hbase.client.Connection;

/**
 * @DATE 2021/12/13/17:51
 * @Author MDK
 * @Version 2021.2.2
 **/
public class C08_DropTable {
    public static void main(String[] args) throws Exception {
        Connection connection = HbaseUtils.getConnection();
        Admin admin = HbaseUtils.getAdmin(connection);
        TableName tb_order = TableName.valueOf("tb_order");

        //判断是否存在
        if(admin.tableExists(tb_order)){
            if(!admin.isTableDisabled(tb_order)){
                admin.disableTable(tb_order);
            }
            admin.deleteTable(tb_order);
        }else {
            System.out.println("目标表不存在");
        }
        admin.close();
        connection.close();
    }
}
